//
//  ZhuanZhangViewController.m
//  1243
//
//  Created by 我的 on 16/4/6.
//  Copyright © 2016年 1243. All rights reserved.
//

#import "ZhuanZhangViewController.h"
#import "ReadLoginData.h"
#import "NetWorkTools.h"

@interface ZhuanZhangViewController ()
@property (weak, nonatomic) IBOutlet UILabel *YuELabel;
@property (weak, nonatomic) IBOutlet UITextField *ZhuanZhangJinE;
@property (weak, nonatomic) IBOutlet UITextField *PhoneNumber;
@property (weak, nonatomic) IBOutlet UITextField *BuyPassWordTextField;

@end

@implementation ZhuanZhangViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.title = @"转账";
    
    NSDictionary *dict = [ReadLoginData readLoginData];
    
    self.YuELabel.text = [NSString stringWithFormat:@"%.1f 元",[[dict objectForKey:@"fh_Money"] floatValue]];
    
//    self.YuELabel.text = @"10.0";
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self clearTextField];
}
- (IBAction)didClickZhuanZhangButton:(id)sender {
   
    [self clearTextField];
    
    NSString *fromUserNum = [NSString stringWithFormat:@"%@",[[ReadLoginData readLoginData] objectForKey:@"Number"]] ;
    
    NSDictionary *dict = @{
                           @"ToUserNum":[NSString stringWithFormat:@"%@",self.PhoneNumber.text],
                           @"FromUserNum":fromUserNum,
                           @"TurnMoney":self.ZhuanZhangJinE.text,
                           @"FromPassword":self.BuyPassWordTextField.text,
                           };
    [[NetWorkTools sharedNetWorkTools] objectWithURLDict:dict AndMenthodName:@"TURNACCOUNT" completeBlock:^(id object) {
        NSLog(@"%@",object)
        
        NSString *message = [object objectForKey:@"Message"];
        
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:message delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        
        [alert show];
        
        [self cleanTextField];
    }];
    
}

- (void)cleanTextField {
    self.ZhuanZhangJinE.text = @"";
    self.PhoneNumber.text = @"";
    self.BuyPassWordTextField.text = @"";
}

- (void)clearTextField {
    [self.ZhuanZhangJinE resignFirstResponder];
    [self.PhoneNumber resignFirstResponder];
    [self.BuyPassWordTextField resignFirstResponder];
}
@end
